package com.haiqi.modules.main.web;

import com.haiqi.common.persistence.dao.DictMapper;
import com.haiqi.common.persistence.entity.Dict;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by zhaoy on 2016/9/20.
 */
@RestController
@RequestMapping("/dict")
public class DictController {

    @Autowired
    private DictMapper dictMapper;

    @RequestMapping("/findByType")
    public List<Dict> findByType(String type){
        List<Dict> dictList = dictMapper.findByType(type);
        return dictList;
    }
    @RequestMapping("/findByTypeAndVal")
    public String findByTypeAndVal(String type,String val){
        String label=null;
        Dict dict = dictMapper.findByTypeAndVal(type,val);
        if(dict!=null){
            label=dict.getLabel();
        }
        return label;
    }
}
